package com.cmcc.sdtp.db;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.jdbc.core.JdbcTemplate;

import com.cmcc.sdtp.util.SdtpSaveSqlUtil;
import com.cmcc.xdr.entity.StatXdrexclogEntity;
import com.cmcc.xdr.message.SingleSigAuthenMsg;
import com.cmcc.xdr.message.SingleSigBiccMsg;
import com.cmcc.xdr.message.SingleSigMsg;
import com.cmcc.xdr.message.SingleSigPccMsg;
import com.cmcc.xdr.message.SingleSigSipMsg;
import com.cmcc.xdr.message.SingleSigSrvccMsg;
import com.cmcc.xdr.message.SynComposedMsg;
import com.cmcc.xdr.util.ProtocolSpringContextUtils;

/**
 * @className：入库
 * @author B
 * @date:
 * @version :
 */
public class SaveSdtpInfo {

	private static Logger logger = LogManager.getLogger(SaveSdtpInfo.class);

	public static final String sipCallSql = "INSERT INTO xdr_sipcall (LENGTH,LOCAL_PROVINCE,LOCAL_CITY,OWNER_PROVINCE,OWNER_CITY,ROAMING_TYPE,INTERFACE,XDR_ID,RAT,IMSI,IMEI,MSISDN,PROCEDURE_TYPE,PROCEDURE_START_TIME,PROCEDURE_END_TIME,SERVICE_TYPE,PROCEDURE_STATUS,CALLING_NUMBER,CALLED_NUMBER,CALLING_PARTY_URI,REQUEST_URI,USER_IP,CALLID,ICID,SOURCE_NE_IP,SOURCE_NE_PORT,DEST_NE_IP,	DEST_NE_PORT,CALL_SIDE,	SOURCE_ACCESS_TYPE,	SOURCE_ECI,SOURCE_TAC,SOURCE_IMSI,SOURCE_IMEI,DEST_ACCESS_TYPE,DEST_ECI,DEST_TAC,DEST_IMSI,DEST_IMEI,CALLING_SDP_IP_ADDR,CALLING_AUDIO_SDP_PORT,CALLING_VIDEO_SDP_PORT,CALLED_SDP_IP_ADDR,CALLED_AUDIO_SDP_PORT,CALLED_VIDEO_PORT,AUDIO_CODEC,VIDEO_CODEC,REDIRECTING_PARTY_ADDRESS,ORIGINAL_PARTY_ADDRESS,REDIRECT_REASON,RESPONSE_CODE,FINISH_WARNING_CODE,FINISH_REASON_PROTOCOL,FINISH_REASON_CAUSE,FIRFAILTIME,FIRST_FAIL_NE_IP,FIRST_FAIL_TRANSACTION,PROGRESS_TIME,PRACK_TIME,ALERTING_TIME,ANSWER_TIME,RELEASE_TIME,CALL_DURATION,INSERT_DATE) VALUES ";//,ATU_STI,C_MSISDN,SSI
	public static final String sipRegSql = "INSERT INTO xdr_sipreg (LENGTH,LOCAL_PROVINCE,LOCAL_CITY,OWNER_PROVINCE,OWNER_CITY,ROAMING_TYPE,INTERFACE,XDR_ID,RAT,IMSI,IMEI,MSISDN,PROCEDURE_TYPE,PROCEDURE_START_TIME,PROCEDURE_END_TIME,PROCEDURE_STATUS,REQUEST_URI,USER_IP,CALLID,ICID,SOURCE_NE_IP,SOURCE_NE_PORT,DEST_NE_IP,DEST_NE_PORT,SOURCE_ACCESS_TYPE,SOURCE_ECI,SOURCE_TAC,AUTH_TYPE,EXPIRES_TIME_REQ,EXPIRES_TIME_RSP,RESPONSE_CODE,FINISH_WARNING_CODE,FINISH_REASON_PROTOCOL,FINISH_REASON_CAUSE,AUTH_REQ_TIME,AUTH_RSP_TIME,INSERT_DATE,STN_SR,ATCF_MGMT) VALUES ";
	public static final String sipSrvccSql = "INSERT INTO xdr_sipsrvcc (LENGTH,LOCAL_PROVINCE,LOCAL_CITY,OWNER_PROVINCE,OWNER_CITY,ROAMING_TYPE,INTERFACE,XDR_ID,RAT,IMSI,IMEI,MSISDN,PROCEDURE_TYPE,PROCEDURE_START_TIME,PROCEDURE_END_TIME,PROCEDURE_STATUS,CALLING_NUMBER,CALLING_PARTY_URI,REQUEST_URI,USER_IP,CALLID,ICID,SOURCE_NE_IP,SOURCE_NE_PORT,DEST_NE_IP,DEST_NE_PORT,SOURCE_ACCESS_TYPE,SOURCE_ECI,SOURCE_TAC,SOURCE_IMSI,SOURCE_IMEI,DEST_ACCESS_TYPE,DEST_ECI,DEST_TAC,DEST_IMSI,DEST_IMEI,CALLING_SDP_IP_ADDR,CALLING_AUDIO_SDP_PORT,CALLING_VIDEO_SDP_PORT,CALLED_SDP_IP_ADDR,CALLED_AUDIO_SDP_PORT,CALLED_VIDEO_PORT,AUDIO_CODEC,VIDEO_CODEC,RESPONSE_CODE,FINISH_WARNING_CODE,FINISH_REASON_PROTOCOL,FINISH_REASON_CAUSE,FIRFAILTIME,FIRST_FAIL_NE_IP,FIRST_FAIL_TRANSACTION,ALERTING_TIME,ANSWER_TIME,RELEASE_TIME,CALL_DURATION,ATU_STI,C_MSISDN,SSI,INSERT_DATE) VALUES ";
	public static final String srvccSql = "INSERT INTO xdr_srvcc (LENGTH,LOCAL_PROVINCE,LOCAL_CITY,OWNER_PROVINCE,OWNER_CITY,ROAMING_TYPE,INTERFACE,XDR_ID,RAT,IMSI,IMEI,MSISDN,PROCEDURE_TYPE,PROCEDURE_START_TIME,PROCEDURE_END_TIME,SOURCE_NE_IP,SOURCE_NE_PORT,DEST_NE_IP,DEST_NE_PORT,ROAM_DIRECTION,HOME_MCC,HOME_MNC,MCC,MNC,TARGET_LAC,SOURCE_TAC,SOURCE_ECI,SV_FLAGS,UL_C_MSC_IP,DL_C_MME_IP,UL_C_MSC_TEID,DL_C_MME_TEID,STN_SR,TARGET_RNC_ID,TARGET_CELL_ID,ARP,REQUEST_RESULT,RESULT,SV_CAUSE,POST_FAILURE_CAUSE,RESP_DELAY,SV_DELAY,INSERT_DATE) VALUES ";
	public static final String pccSql = "INSERT INTO xdr_pcc (LENGTH,LOCAL_PROVINCE,LOCAL_CITY,OWNER_PROVINCE,OWNER_CITY,ROAMING_TYPE,INTERFACE,XDR_ID,RAT,IMSI,IMEI,MSISDN,PROCEDURE_TYPE,PROCEDURE_START_TIME,PROCEDURE_END_TIME,ICID,ORIGIN_REALM,DESTINATION_REALM,ORIGIN_HOST,DESTINATION_HOST,SGSN_SGW_SIG_IP,AF_APP_ID,CC_REQUEST_TYPE,RX_REQUEST_TYPE,MEDIA_TYPE,ABORT_CAUSE,RESULT_CODE,EXPERIMENTAL_RESULT_CODE,SESSION_RELEASE_CAUSE,RULE_FAILURE_CODE,SESSION_ID,IPV6_PREFIX,CALLED_STATION_ID,INSERT_DATE) VALUES ";
	public static final String authenSql = "INSERT INTO xdr_authen (LENGTH,LOCAL_PROVINCE,LOCAL_CITY,OWNER_PROVINCE,OWNER_CITY,ROAMING_TYPE,INTERFACE,XDR_ID,RAT,IMSI,IMEI,MSISDN,PROCEDURE_START_TIME,PROCEDURE_END_TIME,TRANSACTION_TYPE,TRANSACTION_STATUS,SOURCE_NE_IP,SOURCE_NE_PORT,DESTINATION_NE_IP,DESTINATION_NE_PORT,RESULT_CODE,EXPERIMENTAL_RESULT_CODE,ORIGIN_REALM,DESTINATION_REALM,ORIGIN_HOST,DESTINATION_HOST,INSERT_DATE) VALUES ";
	public static final String ncSql = "INSERT INTO xdr_bicc (LENGTH,LOCAL_PROVINCE,LOCAL_CITY,OWNER_PROVINCE,OWNER_CITY,ROAMING_TYPE,INTERFACE,XDR_ID,RAT,IMSI,IMEI,MSISDN,B_TIME,E_TIME,PROTOCOL_ID,SPCKIND,OPC,DPC,PCM,CIC,SLS,CALLING_NUM,CALLED_NUM,O_CALLED_NUM,RECALLED_NUM,MSRN,CALLING_NUM_NATURE,CALLED_NUM_NATURE,O_CALLED_NUM_NATURE,RECALLED_NUM_NATURE,CALLED_STATUS,CALL_TRANS,CALL_TRANS_TYPE,CHARGEIND,EVENT_ID,EVENT_CAUSE,EVENT_RESULT,SEIZURE_DUR,ANSWER_DUR,ACM_OFFSET,ANM_OFFSET,REL_OFFSET,RLC_OFFSET,SAO_OFFSET,ANS_OFFSET,PROCESS1,PROCESS2,PROCESS3,DIRECTION1,DIRECTION2,DIRECTION3,XDR_TYPE,BEAR_TYPE,O_ADDRESSS,D_ADDRESSS,CDR_ID,SESSION_ID,GLOBAL_ID,INSERT_DATE) VALUES ";
	public static final String succomposedSql = "INSERT INTO xdr_suc_composedcall (LENGTH,LOCAL_PROVINCE,LOCAL_CITY,OWNER_PROVINCE,OWNER_CITY,ROAMING_TYPE,RAT,XDR_TYPE,XDR_ID,IMSI,IMEISV,MSISDN,PROCEDURE_TYPE,PROCEDURE_START_TIME,PROCEDURE_END_TIME,PROCEDURE_STATUS,CALLING_NUMBER,CALLED_NUMBER,SERVICE_SCENARIO,XDRNUMBER,SERVICE_TYPE,RESPONSE_CODE,183_REASON_CAUSE,FINISH_REASON_CAUSE,FIRST_FAIL_TIME,FIRST_FAIL_NE_IP,INTERFACE,SINGLE_XDR_ID,SINGLE_PROCEDURE_TYPE,SINGLE_PROCEDURE_START_TIME,SINGLE_PROCEDURE_END_TIME,SINGLE_PROCEDURE_STATUS,SOURCE_NE_IP,SOURCE_NE_PORT,DESTINATION_NE_IP,DESTINATION_NE_PORT,CALL_SIDE,ALERTING_TIME,ANSWER_TIME,SV_RESULT,SV_RESP_DELAY,SV_DELAY,INSERT_DATE) VALUES ";
	public static final String failcomposedSql = "INSERT INTO xdr_fail_composedcall (LENGTH,LOCAL_PROVINCE,LOCAL_CITY,OWNER_PROVINCE,OWNER_CITY,ROAMING_TYPE,RAT,XDR_TYPE,XDR_ID,IMSI,IMEISV,MSISDN,PROCEDURE_TYPE,PROCEDURE_START_TIME,PROCEDURE_END_TIME,PROCEDURE_STATUS,CALLING_NUMBER,CALLED_NUMBER,SERVICE_SCENARIO,XDRNUMBER,SERVICE_TYPE,RESPONSE_CODE,183_REASON_CAUSE,FINISH_REASON_CAUSE,FIRST_FAIL_TIME,FIRST_FAIL_NE_IP,INTERFACE,SINGLE_XDR_ID,SINGLE_PROCEDURE_TYPE,SINGLE_PROCEDURE_START_TIME,SINGLE_PROCEDURE_END_TIME,SINGLE_PROCEDURE_STATUS,SOURCE_NE_IP,SOURCE_NE_PORT,DESTINATION_NE_IP,DESTINATION_NE_PORT,CALL_SIDE,ALERTING_TIME,ANSWER_TIME,SV_RESULT,SV_RESP_DELAY,SV_DELAY,INSERT_DATE) VALUES ";
	public static final String composedRegSql = "INSERT INTO xdr_composedreg (LENGTH,LOCAL_PROVINCE,LOCAL_CITY,OWNER_PROVINCE,OWNER_CITY,ROAMING_TYPE,RAT,XDR_TYPE,XDR_ID,IMSI,IMEISV,MSISDN,PROCEDURE_TYPE,PROCEDURE_START_TIME,PROCEDURE_END_TIME,PROCEDURE_STATUS,CALLING_NUMBER,CALLED_NUMBER,SERVICE_SCENARIO,XDRNUMBER,SERVICE_TYPE,RESPONSE_CODE,183_REASON_CAUSE,FINISH_REASON_CAUSE,FIRST_FAIL_TIME,FIRST_FAIL_NE_IP,INTERFACE,SINGLE_XDR_ID,SINGLE_PROCEDURE_TYPE,SINGLE_PROCEDURE_START_TIME,SINGLE_PROCEDURE_END_TIME,SINGLE_PROCEDURE_STATUS,SOURCE_NE_IP,SOURCE_NE_PORT,DESTINATION_NE_IP,DESTINATION_NE_PORT,CALL_SIDE,ALERTING_TIME,ANSWER_TIME,SV_RESULT,SV_RESP_DELAY,SV_DELAY,INSERT_DATE) VALUES ";

	public static int sqlSize = 1000;//sql入库一次最多条数
    /**
     * 对SSGList中list进行分类
     * @param SSGList
     */
	public static void save(List<SingleSigMsg> SSGList) {	
		Map<String, List<String>> dataList = new HashMap<String, List<String>>();		
		List<String> sipCallList = new ArrayList<String>();
		List<String> sipRegList = new ArrayList<String>();
		List<String> sipSrvccList = new ArrayList<String>();
		List<String> srvccList = new ArrayList<String>();
		List<String> pccList = new ArrayList<String>();
		List<String> ncList = new ArrayList<String>();
		List<String> authenList = new ArrayList<String>();
		List<String> sucComposedList = new ArrayList<String>();
		List<String> failComposedList = new ArrayList<String>();
		List<String> composedRegList = new ArrayList<String>();
		SynComposedMsg sscg = null;
		logger.info("SSGList.size()"+SSGList.size());
		for (SingleSigMsg ssg : SSGList) {
			logger.debug("ssg.getSSGMsg().getInterfaceType() "+ssg.getSSGMsg().getInterfaceType());
			switch (ssg.getSSGMsg().getInterfaceType()) {
			case -1://合成接口
				sscg = (SynComposedMsg) ssg;
				//合成xdr分表
				switch (sscg.getComposed().getProcedureType()) {
				case 5:
					switch (sscg.getComposed().getProcedureStatus()) {
					case 2:
					case 4:
						failComposedList.add(SdtpSaveSqlUtil.sql(((SynComposedMsg) ssg).getComposed()));
						break;
					default:
						sucComposedList.add(SdtpSaveSqlUtil.sql(((SynComposedMsg) ssg).getComposed()));
						break;
					}			
					break;
				default:
					composedRegList.add(SdtpSaveSqlUtil.sql(((SynComposedMsg) ssg).getComposed()));
					break;
				}
				break;
			case 13:
			case 14:
			case 15:
			case 16:
			case 17:
			case 18:
				SingleSigSipMsg sssm = (SingleSigSipMsg) ssg;
				switch (sssm.getProcedureType()) {
				case 1:
				case 2:
				case 3:
				case 4:
					sipRegList.add(SdtpSaveSqlUtil.sql(sssm.getSipreg()));
					break;
				case 5:
					sipCallList.add(SdtpSaveSqlUtil.sql(sssm.getSipcall()));
					break;
				case 6:
					sipSrvccList.add(SdtpSaveSqlUtil.sql(sssm.getSipSrvcc()));
					break;
				case 7:
				case 8:
					break;
				default:
					break;
				}
				break;
			case 19:
				srvccList.add(SdtpSaveSqlUtil.sql(((SingleSigSrvccMsg) ssg).getSrvcc()));
				break;
			case 20:
			case 21:
			case 22:
			case 23:
			case 24:
				authenList.add(SdtpSaveSqlUtil.sql(((SingleSigAuthenMsg) ssg).getAuthen()));
				break;
			case 25:
			case 26:
				pccList.add(SdtpSaveSqlUtil.sql(((SingleSigPccMsg) ssg).getPcc()));
				break;
			case 27:
				SingleSigSipMsg sssm2 = (SingleSigSipMsg) ssg;
				switch (sssm2.getProcedureType()) {
				case 1:
				case 2:
				case 3:
				case 4:
					sipRegList.add(SdtpSaveSqlUtil.sql(sssm2.getSipreg()));
					break;
				case 5:
					sipCallList.add(SdtpSaveSqlUtil.sql(sssm2.getSipcall()));
					break;
				case 6:
					sipSrvccList.add(SdtpSaveSqlUtil.sql(sssm2.getSipSrvcc()));
					break;
				case 7:
				case 8:
					break;
				default:
					break;
				}
				break;
			case 28:
				ncList.add(SdtpSaveSqlUtil.sql(((SingleSigBiccMsg) ssg).getNc()));
				break;
			case 29:
//				logger.error("接口29暂时先扔掉======="+ssg.getSSGMsg().getInterfaceType());
//				sipSrvccList.add(SdtpSaveSqlUtil.sql(((SingleSigSipSrvccMsg) ssg).getSipSrvcc()));
				SingleSigSipMsg sssSrvcc = (SingleSigSipMsg) ssg;
				switch (sssSrvcc.getProcedureType()) {
				case 1:
				case 2:
				case 3:
				case 4:
					sipRegList.add(SdtpSaveSqlUtil.sql(sssSrvcc.getSipreg()));
					break;
				case 5:
					sipCallList.add(SdtpSaveSqlUtil.sql(sssSrvcc.getSipcall()));
					break;
				case 6:
					sipSrvccList.add(SdtpSaveSqlUtil.sql(sssSrvcc.getSipSrvcc()));
					break;
				case 7:
				case 8:
					break;
				default:
					break;
				}
				break;
			default:
				logger.error("其他接口暂时都先扔掉======="+ssg.getSSGMsg().getInterfaceType());
				break;
			}
		}
		dataList.put("sipCallList", sipCallList);
		dataList.put("sipRegList", sipRegList);
		dataList.put("sipSrvccList", sipSrvccList);
		dataList.put("srvccList", srvccList);
		dataList.put("pccList", pccList);
		dataList.put("ncList", ncList);
		dataList.put("authenList", authenList);
		dataList.put("sucComposedList", sucComposedList);
		dataList.put("failComposedList", failComposedList);
		dataList.put("composedRegList", composedRegList);		
		//数据入库
		saveData(dataList);
//		logger.error("2 SSGList.size() "+SSGList.size());		
	}
	/**
	 * 对list进行拆解拼sql入库
	 * @param dataList
	 */
	private static void saveData(Map<String, List<String>> dataList){
    	List<String> sipCallList = dataList.get("sipCallList");
		List<String> sipRegList = dataList.get("sipRegList");
		List<String> sipSrvccList = dataList.get("sipSrvccList");
		List<String> srvccList = dataList.get("srvccList");
		List<String> pccList = dataList.get("pccList");
		List<String> ncList = dataList.get("ncList");
		List<String> authenList = dataList.get("authenList");
		List<String> sucComposedList = dataList.get("sucComposedList");
		List<String> failComposedList = dataList.get("failComposedList");
		List<String> composedRegList = dataList.get("composedRegList");
		if (sipCallList.size() > 0) {
			saveList(sipCallList, "xdr_sipcall", sipCallSql,"sipCallList");
		}
		if (sipRegList.size() > 0) {
			saveList(sipRegList, "xdr_sipreg", sipRegSql,"sipRegList");
		}
		if (sipSrvccList.size() > 0) {
			saveList(sipSrvccList, "xdr_sipSrvcc", sipSrvccSql,"sipSrvccList");
		}
		if (srvccList.size() > 0) {
			saveList(srvccList, "xdr_srvcc", srvccSql,"srvccList");
		}
		if (pccList.size() > 0) {
			saveList(pccList, "xdr_pcc", pccSql,"pccList");
		}
		if (ncList.size() > 0) {
			saveList(ncList, "xdr_bicc", ncSql,"ncList");
		}
		if (authenList.size() > 0) {
			saveList(authenList, "xdr_authen", authenSql,"authenList");
		}
		if (sucComposedList.size() > 0) {
			saveList(sucComposedList, "xdr_suc_composedcall", succomposedSql,"sucComposedList");
		}
		if (failComposedList.size() > 0) {
			saveList(failComposedList, "xdr_fail_composedcall", failcomposedSql,"failComposedList");
		}
		if (composedRegList.size() > 0) {
			saveList(composedRegList, "xdr_composedreg", composedRegSql,"composedRegList");
		}
	}
	/**
	 * 保存list数据
	 * @param st
	 * @param xdrList
	 * @param tableName
	 * @param xdrSql
	 * @param listName
	 * @throws SQLException
	 */
	private static void saveList(List<String> xdrList,String tableName ,String xdrSql,String listName) {
		JdbcTemplate jdbcTemplate = new JdbcTemplate(ProtocolSpringContextUtils.getBean("dataSource"));
		try {
			StringBuffer sql = new StringBuffer();
			if (xdrList.size() > 0) {
				if(xdrList.size() <= sqlSize){
					sql = new StringBuffer(xdrSql);
					for (String string : xdrList) {
						sql.append(string);
						sql.append(",");
	//					sqlValue = string +"&;&";//用来标示入库错误后插入错误信息表
					}
					sql.deleteCharAt(sql.length() - 1);
					sql.append(";");
					logger.debug(xdrList.size() + ":SdtpSaveSqlUtil.sql(sipCallList) "+sql.toString());
					jdbcTemplate.execute(sql.toString());
				}else{
					int bs = 0;//按照sqlSize 的一次入库次数，得到的总共需要执行循环的次数
					int lastSize = 0;//多次循环中最大的一行
					if(xdrList.size() % sqlSize == 0){//如果数量是最大入库行数的倍数则不加1
						bs = xdrList.size() / sqlSize;
					}else{
						bs = xdrList.size() / sqlSize +1;
					}
					logger.info("进入拆分sql,当前总共："+xdrList.size()+"条，需要分："+bs+"次执行");
					for(int y = 0;y < bs ;y++){//如果超过sqlSize条数据，则进行多次拼装sql入库
						sql = new StringBuffer(xdrSql);
						try{
							if(y+1 == bs){//如果是最后一次则直接提取最后的数量
								lastSize = xdrList.size();
							}else{
								lastSize = (y+1)*sqlSize;
							}
							for(int i = y*sqlSize;i < lastSize; i++){
								sql.append(xdrList.get(i));
								sql.append(",");
	//							sqlValue = xdrList.get(i) +"&;&";//用来标示入库错误后插入错误信息表
							}
							sql.deleteCharAt(sql.length() - 1);
							sql.append(";");
							logger.debug(xdrList.size() + ":sql="+sql.toString());
							jdbcTemplate.execute(sql.toString());
						}catch (Exception e) {//多条数据入库时出现问题则将多条数据拆开，一条一条入库
							logger.error("xdrList多数据入库异常，进入数据拆解模式（单条入库）---》");
							String sqlOne = "";
							try {
								for(int i = y*sqlSize;i < lastSize; i++){
									sqlOne = xdrSql+xdrList.get(i) + ";";
									jdbcTemplate.execute(sqlOne);
								}
							} catch (Exception e2) {
								logger.error("xdrList单条数据入库异常=将插入异常信息到异常统计表sql:"+sqlOne+" ----",e2);
								exceptionLogDeal(sqlOne,tableName,listName,"",e2);
							}
						}
					}
				}
			}
		} catch (Exception e) {
			exceptionDeal(jdbcTemplate, xdrList,xdrSql, tableName, listName);
		}
	}
	
	/**
	 * 对异常数据的处理
	 * @param st
	 * @param xdrList
	 * @param tableName
	 * @param listName
	 */
	private static void exceptionDeal(JdbcTemplate jdbcTemplate,List<String> xdrList,String xdrSql,String tableName,String listName){
		if(xdrList.size() > 0){
			logger.error("（未拆分）"+listName+"多数据入库异常，进入数据拆解模式（单条入库）");
			String sqlOne = "";
			try {
				for(int i = 0;i < xdrList.size(); i++){
					sqlOne = xdrSql+xdrList.get(i) + ";";
					jdbcTemplate.execute(sqlOne);						
				}
			} catch (Exception e2) {
				logger.error("（未拆分）"+listName+"单条数据入库异常=将插入异常信息到异常统计表sql:"+sqlOne+" ",e2);
				exceptionLogDeal(sqlOne,tableName,listName,"（未拆分）",e2);
			}
		}
	}
	/**
	 * 对异常数据进行日志记录
	 * @param sqlOne
	 * @param tableName
	 * @param listName
	 * @param prefix
	 * @param e2
	 */
	private static void exceptionLogDeal(String sqlOne,String tableName,String listName,String prefix,Exception e2){
		try {
			String[] val = sqlOne.split("','");//根据','拆分，获取第6个
			String str = val[6];
			if(str != null && !"".equals(val[6])){
				StatXdrexclogEntity statXdrexclog = new StatXdrexclogEntity();
				statXdrexclog.setTablename(tableName);
				statXdrexclog.setInterFace(val[6]);
				statXdrexclog.setExccount(1);
				String errorInfo = e2.getMessage();
				if(errorInfo != null){
					if(errorInfo.length() > 80)
						errorInfo = errorInfo.substring(0, 80);
					errorInfo = errorInfo.replaceAll("'", "");
					statXdrexclog.setExcreason(errorInfo);
				}
				statXdrexclog.setInserttime(new Date());
				SaveExcThread.saveExc(statXdrexclog);
			}
		} catch (Exception e3) {
			logger.error(prefix+listName+"数据单条入库异常=将插入异常信息到异常统计表,解析异常 ",e3);
		}
	}
}